package com.yzf.service;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.yzf.dao.EmployeeDao;
import com.yzf.entity.Employee;
import com.yzf.entity.Project;
import com.yzf.util.web.ServletUtil;

public class new_task extends HttpServlet {

	private static final long serialVersionUID = 1L;


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		Project p = (Project) ServletUtil.getSession(request).getAttribute("project");
		List<Employee> list = new EmployeeDao().findByPid(p.getId());
		ServletUtil.setRequestAttribute("list", list, request);
		ServletUtil.forword(request, response, "new_task");
		
		
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String name = request.getParameter("name");
		String desc = request.getParameter("desc");
		String state = request.getParameter("state");
		String level = request.getParameter("level");
		String begintime = request.getParameter("begintime");
		String endtime = request.getParameter("endtime");
		String employeeid = request.getParameter("employeeid");
		String gid = (String) ServletUtil.getSession(request).getAttribute("goalid"); 
		new TaskService().save(name,desc,state,level,begintime,endtime,employeeid,gid);
		ServletUtil.redirect(response, "/task.jspx?id="+gid);
	}

}
